#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct FenwickTree {
	long long *a;
	long long *b;
	int n;
} FenwickTree;

/*static int
func(int k)
{
	return k & (k+1);
}*/

static long long
rsq_(FenwickTree *fwt, register int idx)
{
	long long sum = 0;
	while (idx >= 0) {
#ifdef DEBUG
		(void) fprintf(stderr, "rsq_(): idx=%d, sum = %lld + %lld\n",
				idx, sum, fwt->b[idx]);
#endif
		sum += fwt->b[idx];
		idx = (idx & (idx + 1)) - 1;
	}
	return sum;
}

long long
rsq(FenwickTree *fwt, int l, int r)
{
#ifdef DEBUG
	(void) fprintf(stderr, "rsq(%d, %d)\n", l, r);
#endif
	return rsq_(fwt, r) - rsq_(fwt, l-1);
}

void
update(FenwickTree *fwt, int idx, long long val)
{
	while (idx < fwt->n) {
		fwt->b[idx] += val;
		idx = idx | (idx + 1);
	}
}

void
init(FenwickTree *fwt)
{
	register int i = 0;
	for (; i < fwt->n ; ++i) {
		update(fwt, i, fwt->a[i]);
	}
}

#ifdef DEBUG
void
print_fancy_fenwick_tree(FenwickTree *fwt)
{
	register int i = 0;
	for (; i < fwt->n ; ++i)
		(void) fprintf(stderr, ", %2lld ", fwt->a[i]);
	fputs(".\n", stderr);
	for (i=0 ; i <fwt->n ; ++i)
		(void) fprintf(stderr, ", %2lld ", fwt->b[i]);
	fputs(".\n", stderr);
	for (i = 0 ; i < fwt->n ; ++i)
		(void) fprintf(stderr, ", %02d ", i+1);
	fputs(".\n\n", stderr);
}
#endif

int
main(void)
{
	int n, k;
	FenwickTree FT;
	/* int i = 0; */
	char buf[512], *c_ptr;
	long long firstarg, secarg;

	(void) scanf("%d%d\n", &n, &k);
	FT.n = n;
	FT.a = (long long*) calloc((size_t) n, sizeof(long long));
	FT.b = (long long*) calloc((size_t) n, sizeof(long long));
	/*init(&FT);*/

	while ((c_ptr = fgets(buf, 255, stdin))) {
		(void) sscanf(c_ptr+2, "%lld%lld", &firstarg, &secarg);
		if (buf[0] == 'A') {
			--firstarg;
			update(&FT, firstarg, secarg - FT.a[firstarg]);
			FT.a[firstarg] = secarg;
		} else if (buf[0] == 'Q') {
			(void) printf("%lld\n", rsq(&FT, --firstarg, --secarg));
		}
#ifdef DEBUG
		(void) fprintf(stderr, " %s", buf);
		print_fancy_fenwick_tree(&FT);
#endif
	}
	free(FT.a);
	free(FT.b);
	return 0;
}
